#ifndef EMPLOYEE_H
#define EMPLOYEE_H

#include "orm.h"
#include "address.h"
#include <QSet>

class Employee : public ORMObject
{
    Q_OBJECT
    Q_PROPERTY(QString name READ name WRITE setName)
    Q_PROPERTY(int age READ age WRITE setAge)
    Q_PROPERTY(QSet<Address*> addresses READ addresses WRITE setAddresses)

public:
    explicit Employee(QObject *parent = nullptr);
    ~Employee();

    QString name() const;
    void setName(const QString &name);

    int age() const;
    void setAge(int age);

    QSet<Address*> addresses() const;
    void setAddresses(const QSet<Address*> &addresses);
    void addAddress(Address* address);

protected:
    virtual void saveChildren() override;
    virtual void loadChildren() override;
    virtual QString tableName() const override { return "employees"; }

private:
    QSet<Address*> m_addresses;
};

REGISTER_ORM_TYPE(Employee)

#endif // EMPLOYEE_H    